home *** CD-ROM | disk | FTP | other *** search
/ FM Towns: Free Software Collection 8 / FM Towns Free Software Collection 8.iso / t_os / 0rc_trn2 / rc_trn2.c < prev    next >
Text File  |  1994-06-01  |  3KB  |  120 lines

  1. /*
  2.     G.C:ラジコン カーの練習だよ
  3.     参考文献:Oh!FMTOWNS 1993/5p156 1994.2p60
  4.     1993.8.7(Sat)-11 94.2.15(Tue)
  5.     (C) by (BigCabinの)小池 増美
  6. */
  7.  
  8. #include <stdio.h>
  9. #include <stdlib.h>
  10. #include <string.h>
  11. #include <math.h>
  12. #include <egb.h>
  13. #include <spr.h>
  14. #include <snd.h>
  15. #include "spr_car.dat"
  16.  
  17. /* macro定義 */
  18. #define TRUE 0
  19. #define PAI 3.1415927
  20. #define BG_COLOR 0x2abc    /* BackGroundColor */
  21. #define START_CAR_X 128    /* 車のスタート位置 */
  22. #define START_CAR_Y 206
  23. #define DR 0.3            /* 加加速度 */
  24. #define DW 0.08            /* 角加速度 */
  25. #define SPEED_MAX 5.0    /* 最高速度 */
  26.  
  27. /* 関数のプロトタイプ宣言 */
  28. int egb_set(void);
  29. int spr_set(void);
  30. int pad_read(int *,int *,int *);
  31. int title(void);
  32. int game_main(void);
  33. int cource_load(char *);
  34.  
  35. /* グローバル変数の宣言 */
  36. char egb_work[1536];
  37.  
  38. /* main routine */
  39. int main(void)
  40. {
  41.     egb_set();
  42.     spr_set();
  43.  
  44.     title();
  45.     cource_load("cource1.tif");
  46.     game_main();
  47.  
  48.     return TRUE;
  49. }
  50.  
  51. /* グラフィックス初期化 */
  52. int egb_set(void)
  53. {
  54.     EGB_init(egb_work,1536);
  55.     EGB_resolution(egb_work,0,10);            /* page0は画面モード10 */
  56.     EGB_resolution(egb_work,1, 5);            /* page1は画面モード 5 */
  57.     EGB_displayPage(egb_work,1,3);            /* 1:画面1を前 3:page1・2共表示 */
  58.  
  59. /* page0の設定 */
  60.     EGB_writePage(egb_work,0);
  61.     EGB_displayStart(egb_work,2,  2,  2);    /* 2:拡大 横2倍 縦2倍 */
  62.     EGB_displayStart(egb_work,3,320,240);    /* 3:表示画面 */
  63.     EGB_displayStart(egb_work,0,  0,  0);    /* 0:画面表示開始位置 */
  64.     EGB_displayStart(egb_work,1,  0,  0);    /* 1:仮想画面中の移動つまりスクロール */
  65.  
  66. /* page1の設定 */
  67.     EGB_writePage(egb_work,1);
  68.     EGB_displayStart(egb_work,2,  2,  2);    /* 2:拡大 横2倍 縦2倍 */
  69.     EGB_displayStart(egb_work,3,256,240);    /* 3:表示画面 */
  70.     EGB_displayStart(egb_work,0, 32,  0);    /* 0:画面表示開始位置 */
  71.     EGB_displayStart(egb_work,1,  0,  2);    /* 1:仮想画面中の移動つまりスクロール */
  72.  
  73.     return TRUE;
  74. }
  75.  
  76. /* スプライトの初期化 */
  77. int spr_set(void)
  78. {
  79.     int i;
  80.  
  81.     SPR_init();
  82.  
  83.     for(i=0;i < 8;++i)
  84.     {
  85.         /* パターン設定(メインキャラクタ) */
  86.         /* パターン格納部(128~159)にデータを入れる */
  87.         SPR_define(1,128+i*4,1,1,(char*)spr_ptn[7-i]);
  88.         /* 1:32K色 128:先頭パターン番号1:横スプライト数 1:縦スプライト数 */
  89.         
  90.         /* インデックス格納部(1023~1016)にアトリビュートと位置を設定 */
  91.         SPR_setAttribute(1023-i,1,1,128+i*4,0);
  92.         /* 1020:先頭スプライト番号 2:横スプライト数 2:縦スプライト数                       128:パターン番号 0:色テーブル番号(32K色だから0) */
  93.         
  94.         SPR_setPosition(0,1023-i,1,1,START_CAR_X,START_CAR_Y);                          /* 128,120:画面の中央 */
  95.     }
  96.     return TRUE;
  97. }
  98.  
  99. /* パッドの読み取り */
  100. int pad_read(int *sr,int *ab,int *pd)
  101. {
  102.     int port;
  103.     
  104.     SND_joy_in_2(0,&port);    /* 読み取り 0:左ポート(端子) &port:ポートの状態 */
  105.     /* 上のデータを各ボタンデータに変換(0と1をも入れ換える) */
  106.     *sr=((port>>6)&0x03)^0x03;    /* select・runボタン */
  107.     *ab=((port>>4)&0x03)^0x03;    /*      A・B  ボタン */
  108.     *pd=(port&0x0f)^0x0f;        /*      方向 ボタン */
  109.     
  110.     return TRUE;
  111. }
  112.  
  113. /* タイトル画面を表示する */
  114. #include "rc_title.c"
  115.  
  116. /* game main routine */
  117. #include "rc_main.c"
  118.  
  119. /* TIFF画像の読込 */
  120. #include "rc_tifld.c"